<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>知识荟</title>
    <link rel="stylesheet" href="../css/spaces-member-main.css">
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/space-member.js"></script>
</head>

<body>
<!--**************顶部导航****************-->
<%@include file="../jsp/common/nav.jsp"%>
<!--**************左侧导航****************-->
<%@include file="../jsp/common/sidebar-scroll.jsp"%>
<!--***************空间成员主界面*******************-->
<c:set var="user" value="${sessionScope.user}"/>
<c:set var="space" value="${sessionScope.space}"/>
<div class="right">
    <!--标题导航-->
    <div class="member-nav">
        <span class="member-nav-title"><a href="/index/main?id=${user.id}">学习空间</a></span>
        >
        <span class="member-nav-title"><a href="/index/space-main?space_id=${space.id}&name=${space.name}">${space.name}</a></span>
        >
        <span>成员</span>
    </div>
    <div class="member-detail">
        <h2>空间成员</h2>
        <span>用户只能通过邀请链接加入私有空间。公开的空间转换为私有空间时，会保留所有空间成员</span>
    </div>
    <div class="member">
        <div class="member-title">
            <form action="/member/selectMember" method="post">
                <h5>空间名称</h5><span class="member-title-span">的成员</span>
                <span class="member-count">${memberCount}</span>
                <div class="input">
                    <input type="text" class="text" name="username" placeholder="按名称查找成员" value="${username}"/>
                    <input type="submit" class="submit" value="查找" />
                </div>
            </form>
        </div>
        <c:forEach items="${memberList}" var="member">
            <div class="member-item">
                <div class="item-left">
                    <img src="../images/member-logo.jpg" />
                    <h5><a href="/users/user-dongtai?id=${member.id}" >${member.username}</a></h5>
                    <span class="member-item-span">加入于:
                    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                    value="${member.join_time}" />
                </span>
                </div>
                <div class="item-right">
                    <select name="status" id="status" value="${member.status}" onchange="updateStatus(this.options[this.options.selectedIndex].value,${member.id})">
                        <option value="${member.status}" <c:if test="${member.status==1}">selected</c:if>>
                            成员
                        </option>
                        <option value="${member.status}" <c:if test="${member.status==2}">selected</c:if>>
                            管理员
                        </option>
                    </select>
                </div>
            </div>
        </c:forEach>
    </div>
    <c:if test="${requestScope.msg!=null}">
        <!--当查询结果没有时，给用户提示信息： -->
        <li style="border-top:1px solid #ccc;height: 40px;line-height: 40px;" >
            <center><font color="gray" size="2"  >${requestScope.msg}</font></center>
        </li>
    </c:if>

    <!--***************分页****************-->
    <div class="page">
        <ul>
            <li class="page_li">
                <a class="page_btn"id="prePage" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage-1}">
                    <
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn1" href="${pageContext.request.contextPath}/member/space-member?page=1">
                    1
                </a>
            </li>
            <li class="page_li"> <span class="pages_span" id="prePoint">...</span> </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn2" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage-2}">
                    ${currentPage-2}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn3" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage-1}">
                    ${currentPage-1}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn4" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage}">
                    ${currentPage}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn5" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage+1}">
                    ${currentPage+1}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn6" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage+2}">
                    ${currentPage+2}
                </a>
            </li>
            <li class="page_li"> <span class="pages_span" id="sufPoint">...</span> </li>
            <li class="page_li">
                <a class="page_btn" id="page_btn7" href="${pageContext.request.contextPath}/member/space-member?page=${pageTotal}">
                    ${pageTotal}
                </a>
            </li>
            <li class="page_li">
                <a class="page_btn" id="sufPage" href="${pageContext.request.contextPath}/member/space-member?page=${currentPage+1}">
                    >
                </a>
            </li>
        </ul>
    </div>
</div>
</body>
</html>

